package store.lunangangster.engine.impl.auth;

import java.util.HashMap;
import java.util.Map;

public class Authentication {

  protected static final ThreadLocal<String> USER_ID_TL = new ThreadLocal<>();
  protected static final ThreadLocal<String> GROUP_TL = new ThreadLocal<>();

  public static void setUserId(String userId) {
    USER_ID_TL.set(userId);
  }

  public static void setGroup(String group) {
    GROUP_TL.set(group);
  }

  public static String getUserId() {
    return USER_ID_TL.get();
  }

  public static String getGroup() {
    return GROUP_TL.get();
  }

  public static void removeUserId() {
    USER_ID_TL.remove();
  }

  public static void removeGroup() {
    GROUP_TL.remove();
  }

  public static Object getAuthentication() {
    Map<String, Object> map = new HashMap<>();

    map.put("user", getUserId());
    map.put("group", getGroup());

    return map;
  }
}
